package com.cl.mypureframe.adapter;

import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.viewpager.widget.PagerAdapter;

import java.util.List;

/**
 * @Class: GuideViewAdapter
 * @Description:
 * @Author: ChenLei
 * @Date: 2020/11/19---16:52
 */
public class GuideViewAdapter extends PagerAdapter {
    private final List<View> list;

    public GuideViewAdapter(List<View> list) {
        this.list = list;

    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public boolean isViewFromObject(@NonNull View arg0, @NonNull Object arg1) {
        return arg0 == arg1;
    }

    @Override
    public void destroyItem(ViewGroup view, int position, @NonNull Object object) {
        view.removeView(list.get(position));
    }

    @NonNull
    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(list.get(position));
        return list.get(position);
    }

}
